<template>
  <div class="box">
    <div v-for="(item, index) in arr" :key="index">
      <span>{{ item }}</span>
      <input type="checkbox" :value="item" v-model="othersum" >
    </div>
    <br>
    <p>你选中的元素，加起来的和的值为{{ allSum }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [9, 15, 19, 25, 29, 31, 48, 57, 62, 79, 87],
      othersum: [],
    }
  },
  computed: {
    allSum() {
      return this.othersum.reduce((sum, item) => {
        // console.log(sum, item)
        return (sum += item)
      }, 0) 
    }
  }
}
</script>

<style>
.box {
  display: flex;
}
</style>